<?php
include "config.php";//apikey配置文件
include "jd/JdClient.php";//请求文件
include "jd/RequestCheckUtil.php";//请求文件
include "jd/request/UnionOpenCouponQueryRequest.php";//接口参数

$AppKey=$ApiConfig["AppKey"];
$AppSecret=$ApiConfig["AppSecret"];

$c = new JdClient();
$c->appKey = $ApiConfig["AppKey"];
$c->appSecret = $ApiConfig["AppSecret"];

$req = new UnionOpenCouponQueryRequest();
$couponUrls= ["http://coupon.m.jd.com/coupons/show.action?key=14c032be3e834ad8ba30f5780b29318b&roleId=64785352&to=jiujiangguan.jd.com"];
$req->setCouponUrls($couponUrls);
$resp = $c->execute($req);
// print_r($resp);

function get_coupon_info($coupon_url){
	global $AppKey;
	global $AppSecret;
	$c = new JdClient();
	$c->appKey = $AppKey;
	$c->appSecret = $AppSecret;
	
	$req = new UnionOpenCouponQueryRequest();
	$couponUrls= [$coupon_url];
	$req->setCouponUrls($couponUrls);
	$resp = $c->execute($req);
	return json_decode($resp -> jd_union_open_coupon_query_responce -> queryResult,true);
}